package servlet;

import model.User;
import service.UserService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpdateUser_Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        UserService service = new UserService();
        String user_name = req.getParameter("name");
        String user_password = req.getParameter("password");
        String Email = req.getParameter("Email");
        String real_name = req.getParameter("real_name");
        String tel = req.getParameter("tel");
        String sex = req.getParameter("sex");
        String data_birth = req.getParameter("data_birth");
        User user = new User(user_name, user_password, Email, real_name, tel, sex, data_birth);
        if(service.modifyUserInfo(user)){
            System.out.println("serlet修改成功");
        }else {
            System.out.println("serlet修改失败");
        }
        resp.sendRedirect("main/userInfo.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
